const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack')
const Mock = require('mockjs')
const data = Mock.mock({
  "list|5": [{
    "url": "@image(100x100, @color)",
    "desc": "@cword(10,20)"
  }]
})
module.exports = {
  mode: 'none',
  entry: './src/main.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'main.js',
    clean: true,
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: './src/index.html'
    }),
    new webpack.HotModuleReplacementPlugin()
  ],
  module: {
    rules: [{
        test: /\.styl$/,
        use: [
          "style-loader",
          "css-loader",
          "stylus-loader"
        ], 
      },
      {
        test: /\.scss$/,
        use: [
          "style-loader",
          "css-loader",
          "sass-loader"
        ], 
      },
    ],
  },
  devServer: {
    hot: true,
    before(app) {
      app.get('/list', (req, res) => {
        res.json(data.list)
      })
    }
  }
}